<!--打包记录-->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" />
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">

    </ex_super_table_page>


    <print_outbound_track ref="print_outbound_track" :tableModel="[
      { key: 'outOrderNo', label: 'label_outbound_code', 'min-width': 140, },
      { key: 'trackNumber', label: 'label_track_or_package_code', 'min-width': 140, },
    ]" />

  </div>
</template>

<script>
import print_outbound_track from '@/component/print/print_outbound_track'

import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import router_params from '@/mixin/router_params';

let emitKey = 'outbound>check_pack_record'
import emitOnFunction from '@/mixin/emit-on-function';
export default {
  title: "title_standard_check_pack_record",
  mixins: [superTablePageFunction, router_params, emitOnFunction(emitKey), page_table_model_manage],
  components: { print_outbound_track, },
  data() {
    return {
      isConfirm_routeParamsChange: false,
      option: {
        search: {
          model: [
            { label: "label_outbound_code", key: "outOrderNo", },
            { label: "label_check_pack_user", key: "userName", },
            { label: "label_tms_common_carrier", key: "supplierName", },
            { label: "label_sku", key: "skuId", type: "sku_selec_input" },
            {
              label: "label_create_time", key: "startDate", type: 'date-picker', attrs: { type: 'datetime' },
              render: (h, { data, item }) => {
                const limitKey = 'endDate'; const limitValue = data[limitKey]; const value = data[item.key];
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_start_time"
                  attrs={{ type: 'datetime' }} pickerOptions={{ disabledDate: date => { return limitValue ? (limitValue < date.getTime()) : false } }}
                />)
              }
            },
            {
              label: "~", key: "endDate", type: 'date-picker', attrs: { type: 'datetime' },
              render: (h, { data, item }) => {
                const limitKey = 'startDate'; const limitValue = data[limitKey]; const value = data[item.key];
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_end_time"
                  attrs={{ type: 'datetime', 'default-time': '23:59:59' }} pickerOptions={{ disabledDate: date => { return limitValue ? (limitValue > date.getTime()) : false } }}
                />)
              }
            },
          ],

        },
        actionExtra: [
          {
            label: { _key: "label_print_any", type: "label_self_draw_face_track", i18n: true }, attrs: { type: "primary" }, click: (row) => {
              if (_.isEmpty(this.selection)) {
                return this.$message.error(this.$tt('tip_please_select_order'))
              } else if (this.selection.some(row => !this.checkSelfTempPrint(row))) {
                this.$message.error(this.selection.map(o => o.trackNumber).join() + " ;" + this.$t('tip_status_error_no_operate'))
                return
              }
              this.$refs.print_outbound_track.show(this.selection, { thirdParty: false })
            }
          },
          {
            label: { _key: "label_print_any", type: "label_third_party_face_track", i18n: true }, attrs: { type: "primary" }, click: (row) => {
              if (_.isEmpty(this.selection)) {
                return this.$message.error(this.$tt('tip_please_select_order'))
              } else if (this.selection.some(row => !this.checkThreeTrackPrint(row))) {
                this.$message.error(this.selection.map(o => o.trackNumber).join() + " ;" + this.$t('tip_status_error_no_operate'))
                return
              }
              this.$refs.print_outbound_track.show(this.selection, { thirdParty: true })
            }
          },
        ],
        table: {
          url: "/wms-api/outbound/OutboundBoxPackageRpc/select.json",
          urlDataHandle: this.urlDataHandle,
          model: this.init_table_model(),
        }
      },
    };
  },

  mounted() {

  },

  methods: {
    urlDataHandle(res) {
      const list = res && res.data && res.data.rows ? res.data.rows : []
      list.forEach(it => it.platformCode = it.ecPlatformName)
      return list
    },
    checkSelfTempPrint(track) {
      return !track.labelOssPath || track.platformCode == "Wildberries"
    },
    checkThreeTrackPrint(track) {
      return !!track.labelOssPath
    },
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true, keyGroup: 'label_table_operate' },

        { key: 'outOrderNo', label: 'label_outbound_code', 'min-width': 140, },
        { key: 'trackNumber', label: 'label_track_or_package_code', 'min-width': 120, },
        // { key: 'bizType', label: 'label_business_type', 'width': 120, formatter: (r, c, v) => this.$enumShow(v, "BizTypeEnum") },

        { key: 'packageBoxNos', label: 'label_box_code', 'min-width': 120, },
        {
          key: 'customerName', label: 'label_customer_name', 'width': 140, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$formatNameCode(v, r.customerCode, null)
        },
        { key: 'packingType', label: 'label_pack_material_type', 'width': 120, 'show-overflow-tooltip': true, },
        { key: 'packingName', label: 'label_pack_material_name', 'width': 120, 'show-overflow-tooltip': true, },
        { key: 'gmtCreate', label: 'label_audit_confirm_time', 'width': 130, formatter: (r, c, v, i) => this.$dateFormat(v) },


        { key: 'weight', label: 'label_check_pack_weight', 'width': 80, 'show-overflow-tooltip': true, },
        { key: 'volume', label: 'label_check_pack_volume', 'width': 80, 'show-overflow-tooltip': true, },
        { key: 'scansCount', label: 'label_sku_count', 'width': 80, },
        {
          key: 'supplierName', label: 'label_pms_supply', 'width': 100, 'show-overflow-tooltip': true
        },
        { key: 'packPerson', label: 'label_check_pack_user', 'width': 120, 'show-overflow-tooltip': true, },
        {
          key: 'heavyCargoFlag', label: 'label_is_heavy_good', 'width': 100,
          formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum"),
        },
        { key: 'printCount', label: 'label_print_count', 'width': 80, },
        {
          type: 'operate', width: 160, operate: [
            {
              label: 'label_self_draw_face_track', if: (row) => this.checkSelfTempPrint(row),
              click: (row) => this.$refs.print_outbound_track.show([row], {
                extraBusinessType: this.checkThreeTrackPrint(row) ? row.platformCode : null,
                thirdParty: false, single: true,
              }),
            },
            {
              label: 'label_third_party_face_track', if: (row) => this.checkThreeTrackPrint(row),
              click: (row) => this.$refs.print_outbound_track.show([row], {
                extraBusinessType: row.platformCode,
                thirdParty: true, single: true,
              }),
            },
          ]
        },
      ]
    },
    init_data_default(into_params) {
      if (this.$refs['SuperTablePage']) {
        this.$refs['SuperTablePage'].setSearchData(Object.assign({}, this.$refs['SuperTablePage'].getSearchData(), into_params))
        // this.$nextTick(() => {
        //   this.$refs['SuperTablePage'].loadDataForSearch()
        // })
      }

    },
  }
};

</script>
<style></style>
